<?php
/**
 *
 * Copyright (c) 2009, Persistent Systems Limited
 *
 * Redistribution and use, with or without modification, are permitted
 *  provided that the following  conditions are met:
 *   - Redistributions of source code must retain the above copyright notice,
 *     this list of conditions and the following disclaimer.
 *   - Neither the name of Persistent Systems Limited nor the names of its contributors
 *     may be used to endorse or promote products derived from this software
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/**
 * This code was generated by the tool 'PHPDataSvcUtil.php'.
 * Runtime Version:1.0
 *
 * Changes to this file may cause incorrect behavior and will be lost if
 * the code is regenerated.
 */

// Get ADO .NET Data Services PHP Toolkit library path
$library_path = get_cfg_var('adodotnetservicesphp_path');
if (strlen($library_path) == 0)
{
    throw new Exception("The configuration option 'adodotnetservicesphp_path' is not set in the php.ini file, "
                        . "Please refer installation instructions for fix this issue");
}

// Refer phpdataservices framework classes
require_once 'Resource/Messages.php';
require_once 'Common/Dictionary.php';
require_once 'Context/EntityStates.php';
require_once 'Interfaces/Entity.php';
require_once 'Context/ResourceBox.php';
require_once 'Context/RelatedEnd.php';
require_once 'Context/SaveResult.php';
require_once 'Common/Guid.php';
require_once 'Credential/Credential.php';
require_once 'Common/Utility.php';
require_once 'Context/QueryProcessor.php';
require_once 'Context/ObjectContext.php';
require_once 'Parser/Parser.php';
require_once 'Parser/AtomParser.php';
require_once 'Parser/JSONParser.php';
require_once 'Interfaces/Object.php';
require_once 'WebUtil/HttpBatchRequest.php';
require_once 'WebUtil/HttpBatchResponse.php';
require_once 'WebUtil/HttpRequest.php';
require_once 'WebUtil/Microsoft_Http_Response.php';
require_once 'WebUtil/HttpResponse.php';
require_once 'HttpProxy.php';
require_once 'ADODotNETDataServicesException.php';

/**
 * Defines default ADO .NET Data Service URL for this proxy class
 */
define("DEFAULT_ADO_DOT_NET_SERVICE_URL", "http://localhost:8080/NorthwindDataService.svc/");

/**
 * The Categories class
 */
class Categories extends Object
{
    protected $_entityMap = array();
    protected $_entityKey = array();
    protected $_relLinks  = array();
    protected $_baseURI;
    
    /**
     * EntityProperty
     * NotNullable
     * Edm.Int32
     */
    public $CategoryID;
    /**
     * EntityProperty
     * NotNullable
     * Edm.String
     */
    public $CategoryName;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Description;
    /**
     * EntityProperty
     * Edm.Binary
     */
    public $Picture;
    /**
     * NavigationProperty
     */
    public $Products;

    /**
     * Function to create an instance of Categories
     */
    public static function CreateCategories($CategoryID, $CategoryName)
    {   
        $Categories = new Categories();
        $Categories->CategoryID = $CategoryID;
        $Categories->CategoryName = $CategoryName;
        return $Categories;
    }

    /**
     * Constructor for Categories
     */
    public function __construct($uri = "")
    {
        $this->_objectID = Guid::NewGuid();        
        $this->_baseURI = $uri;
        
        $this->_entityMap['Products'] = 'Products';
        
        $this->_entityKey[] = 'CategoryID';
    
    }

    /**
     * overring getObjectID() functon of Object class
     */
    public function getObjectID()
    {
        return $this->_objectID;
    }

    /**
     * This function returns the entity keys of this entity.
     */
    public function getEntityKeys()
    {
        return $this->_entityKey;
    }

    /**
     * This function set the entity keys of this entity.
     */
    public function setEntityKeys($entityKey)
    {
        $this->_entityKey = $entityKey;
    }

    /**
     * This function returns the related links of this entity.
     */
    public function getRelatedLinks()
    {
        return $this->_relLinks;
    }

    /**
     * This function set the related links of this entity.
     */
    public function setRelatedLinks($relLinks)
    {
        $this->_relLinks = $relLinks;
    }

    /**
     * Function for getting Entity Type Name corrosponding to navigation Name
     */
    public function getActualEntityTypeName($key)
    {
        if (array_key_exists  ($key, $this->_entityMap))
        {
            return ($this->_entityMap[$key]);
        }

        return $key;
    }
}

/**
 * The CustomerDemographics class
 */
class CustomerDemographics extends Object
{
    protected $_entityMap = array();
    protected $_entityKey = array();
    protected $_relLinks  = array();
    protected $_baseURI;
    
    /**
     * EntityProperty
     * NotNullable
     * Edm.String
     */
    public $CustomerTypeID;
    /**
     * EntityProperty
     * Edm.String
     */
    public $CustomerDesc;
    /**
     * NavigationProperty
     */
    public $Customers;

    /**
     * Function to create an instance of CustomerDemographics
     */
    public static function CreateCustomerDemographics($CustomerTypeID)
    {   
        $CustomerDemographics = new CustomerDemographics();
        $CustomerDemographics->CustomerTypeID = $CustomerTypeID;
        return $CustomerDemographics;
    }

    /**
     * Constructor for CustomerDemographics
     */
    public function __construct($uri = "")
    {
        $this->_objectID = Guid::NewGuid();        
        $this->_baseURI = $uri;
        
        $this->_entityMap['Customers'] = 'Customers';
        
        $this->_entityKey[] = 'CustomerTypeID';
    
    }

    /**
     * overring getObjectID() functon of Object class
     */
    public function getObjectID()
    {
        return $this->_objectID;
    }

    /**
     * This function returns the entity keys of this entity.
     */
    public function getEntityKeys()
    {
        return $this->_entityKey;
    }

    /**
     * This function set the entity keys of this entity.
     */
    public function setEntityKeys($entityKey)
    {
        $this->_entityKey = $entityKey;
    }

    /**
     * This function returns the related links of this entity.
     */
    public function getRelatedLinks()
    {
        return $this->_relLinks;
    }

    /**
     * This function set the related links of this entity.
     */
    public function setRelatedLinks($relLinks)
    {
        $this->_relLinks = $relLinks;
    }

    /**
     * Function for getting Entity Type Name corrosponding to navigation Name
     */
    public function getActualEntityTypeName($key)
    {
        if (array_key_exists  ($key, $this->_entityMap))
        {
            return ($this->_entityMap[$key]);
        }

        return $key;
    }
}

/**
 * The Customers class
 */
class Customers extends Object
{
    protected $_entityMap = array();
    protected $_entityKey = array();
    protected $_relLinks  = array();
    protected $_baseURI;
    
    /**
     * EntityProperty
     * NotNullable
     * Edm.String
     */
    public $CustomerID;
    /**
     * EntityProperty
     * NotNullable
     * Edm.String
     */
    public $CompanyName;
    /**
     * EntityProperty
     * Edm.String
     */
    public $ContactName;
    /**
     * EntityProperty
     * Edm.String
     */
    public $ContactTitle;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Address;
    /**
     * EntityProperty
     * Edm.String
     */
    public $City;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Region;
    /**
     * EntityProperty
     * Edm.String
     */
    public $PostalCode;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Country;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Phone;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Fax;
    /**
     * NavigationProperty
     */
    public $Orders;
    /**
     * NavigationProperty
     */
    public $CustomerDemographics;

    /**
     * Function to create an instance of Customers
     */
    public static function CreateCustomers($CustomerID, $CompanyName)
    {   
        $Customers = new Customers();
        $Customers->CustomerID = $CustomerID;
        $Customers->CompanyName = $CompanyName;
        return $Customers;
    }

    /**
     * Constructor for Customers
     */
    public function __construct($uri = "")
    {
        $this->_objectID = Guid::NewGuid();        
        $this->_baseURI = $uri;
        
        $this->_entityMap['Orders'] = 'Orders';
        
        $this->_entityMap['CustomerDemographics'] = 'CustomerDemographics';
        
        $this->_entityKey[] = 'CustomerID';
    
    }

    /**
     * overring getObjectID() functon of Object class
     */
    public function getObjectID()
    {
        return $this->_objectID;
    }

    /**
     * This function returns the entity keys of this entity.
     */
    public function getEntityKeys()
    {
        return $this->_entityKey;
    }

    /**
     * This function set the entity keys of this entity.
     */
    public function setEntityKeys($entityKey)
    {
        $this->_entityKey = $entityKey;
    }

    /**
     * This function returns the related links of this entity.
     */
    public function getRelatedLinks()
    {
        return $this->_relLinks;
    }

    /**
     * This function set the related links of this entity.
     */
    public function setRelatedLinks($relLinks)
    {
        $this->_relLinks = $relLinks;
    }

    /**
     * Function for getting Entity Type Name corrosponding to navigation Name
     */
    public function getActualEntityTypeName($key)
    {
        if (array_key_exists  ($key, $this->_entityMap))
        {
            return ($this->_entityMap[$key]);
        }

        return $key;
    }
}

/**
 * The Employees class
 */
class Employees extends Object
{
    protected $_entityMap = array();
    protected $_entityKey = array();
    protected $_relLinks  = array();
    protected $_baseURI;
    
    /**
     * EntityProperty
     * NotNullable
     * Edm.Int32
     */
    public $EmployeeID;
    /**
     * EntityProperty
     * NotNullable
     * Edm.String
     */
    public $LastName;
    /**
     * EntityProperty
     * NotNullable
     * Edm.String
     */
    public $FirstName;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Title;
    /**
     * EntityProperty
     * Edm.String
     */
    public $TitleOfCourtesy;
    /**
     * EntityProperty
     * Edm.DateTime
     */
    public $BirthDate;
    /**
     * EntityProperty
     * Edm.DateTime
     */
    public $HireDate;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Address;
    /**
     * EntityProperty
     * Edm.String
     */
    public $City;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Region;
    /**
     * EntityProperty
     * Edm.String
     */
    public $PostalCode;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Country;
    /**
     * EntityProperty
     * Edm.String
     */
    public $HomePhone;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Extension;
    /**
     * EntityProperty
     * Edm.Binary
     */
    public $Photo;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Notes;
    /**
     * EntityProperty
     * Edm.String
     */
    public $PhotoPath;
    /**
     * NavigationProperty
     */
    public $Employees1;
    /**
     * NavigationProperty
     */
    public $Employees2;
    /**
     * NavigationProperty
     */
    public $Orders;
    /**
     * NavigationProperty
     */
    public $Territories;

    /**
     * Function to create an instance of Employees
     */
    public static function CreateEmployees($EmployeeID, $LastName, $FirstName)
    {   
        $Employees = new Employees();
        $Employees->EmployeeID = $EmployeeID;
        $Employees->LastName = $LastName;
        $Employees->FirstName = $FirstName;
        return $Employees;
    }

    /**
     * Constructor for Employees
     */
    public function __construct($uri = "")
    {
        $this->_objectID = Guid::NewGuid();        
        $this->_baseURI = $uri;
        
        $this->_entityMap['Employees1'] = 'Employees1';
        
        $this->_entityMap['Employees2'] = 'Employees';
        
        $this->_entityMap['Orders'] = 'Orders';
        
        $this->_entityMap['Territories'] = 'Territories';
        
        $this->_entityKey[] = 'EmployeeID';
    
    }

    /**
     * overring getObjectID() functon of Object class
     */
    public function getObjectID()
    {
        return $this->_objectID;
    }

    /**
     * This function returns the entity keys of this entity.
     */
    public function getEntityKeys()
    {
        return $this->_entityKey;
    }

    /**
     * This function set the entity keys of this entity.
     */
    public function setEntityKeys($entityKey)
    {
        $this->_entityKey = $entityKey;
    }

    /**
     * This function returns the related links of this entity.
     */
    public function getRelatedLinks()
    {
        return $this->_relLinks;
    }

    /**
     * This function set the related links of this entity.
     */
    public function setRelatedLinks($relLinks)
    {
        $this->_relLinks = $relLinks;
    }

    /**
     * Function for getting Entity Type Name corrosponding to navigation Name
     */
    public function getActualEntityTypeName($key)
    {
        if (array_key_exists  ($key, $this->_entityMap))
        {
            return ($this->_entityMap[$key]);
        }

        return $key;
    }
}

/**
 * The Order_Details class
 */
class Order_Details extends Object
{
    protected $_entityMap = array();
    protected $_entityKey = array();
    protected $_relLinks  = array();
    protected $_baseURI;
    
    /**
     * EntityProperty
     * NotNullable
     * Edm.Int32
     */
    public $OrderID;
    /**
     * EntityProperty
     * NotNullable
     * Edm.Int32
     */
    public $ProductID;
    /**
     * EntityProperty
     * NotNullable
     * Edm.Decimal
     */
    public $UnitPrice;
    /**
     * EntityProperty
     * NotNullable
     * Edm.Int16
     */
    public $Quantity;
    /**
     * EntityProperty
     * NotNullable
     * Edm.Single
     */
    public $Discount;
    /**
     * NavigationProperty
     */
    public $Orders;
    /**
     * NavigationProperty
     */
    public $Products;

    /**
     * Function to create an instance of Order_Details
     */
    public static function CreateOrder_Details($OrderID, $ProductID, $UnitPrice, $Quantity, $Discount)
    {   
        $Order_Details = new Order_Details();
        $Order_Details->OrderID = $OrderID;
        $Order_Details->ProductID = $ProductID;
        $Order_Details->UnitPrice = $UnitPrice;
        $Order_Details->Quantity = $Quantity;
        $Order_Details->Discount = $Discount;
        return $Order_Details;
    }

    /**
     * Constructor for Order_Details
     */
    public function __construct($uri = "")
    {
        $this->_objectID = Guid::NewGuid();        
        $this->_baseURI = $uri;
        
        $this->_entityMap['Orders'] = 'Orders';
        
        $this->_entityMap['Products'] = 'Products';
        
        $this->_entityKey[] = 'OrderID';
    
        $this->_entityKey[] = 'ProductID';
    
    }

    /**
     * overring getObjectID() functon of Object class
     */
    public function getObjectID()
    {
        return $this->_objectID;
    }

    /**
     * This function returns the entity keys of this entity.
     */
    public function getEntityKeys()
    {
        return $this->_entityKey;
    }

    /**
     * This function set the entity keys of this entity.
     */
    public function setEntityKeys($entityKey)
    {
        $this->_entityKey = $entityKey;
    }

    /**
     * This function returns the related links of this entity.
     */
    public function getRelatedLinks()
    {
        return $this->_relLinks;
    }

    /**
     * This function set the related links of this entity.
     */
    public function setRelatedLinks($relLinks)
    {
        $this->_relLinks = $relLinks;
    }

    /**
     * Function for getting Entity Type Name corrosponding to navigation Name
     */
    public function getActualEntityTypeName($key)
    {
        if (array_key_exists  ($key, $this->_entityMap))
        {
            return ($this->_entityMap[$key]);
        }

        return $key;
    }
}

/**
 * The Orders class
 */
class Orders extends Object
{
    protected $_entityMap = array();
    protected $_entityKey = array();
    protected $_relLinks  = array();
    protected $_baseURI;
    
    /**
     * EntityProperty
     * NotNullable
     * Edm.Int32
     */
    public $OrderID;
    /**
     * EntityProperty
     * Edm.DateTime
     */
    public $OrderDate;
    /**
     * EntityProperty
     * Edm.DateTime
     */
    public $RequiredDate;
    /**
     * EntityProperty
     * Edm.DateTime
     */
    public $ShippedDate;
    /**
     * EntityProperty
     * Edm.Decimal
     */
    public $Freight;
    /**
     * EntityProperty
     * Edm.String
     */
    public $ShipName;
    /**
     * EntityProperty
     * Edm.String
     */
    public $ShipAddress;
    /**
     * EntityProperty
     * Edm.String
     */
    public $ShipCity;
    /**
     * EntityProperty
     * Edm.String
     */
    public $ShipRegion;
    /**
     * EntityProperty
     * Edm.String
     */
    public $ShipPostalCode;
    /**
     * EntityProperty
     * Edm.String
     */
    public $ShipCountry;
    /**
     * NavigationProperty
     */
    public $Customers;
    /**
     * NavigationProperty
     */
    public $Employees;
    /**
     * NavigationProperty
     */
    public $Order_Details;
    /**
     * NavigationProperty
     */
    public $Shippers;

    /**
     * Function to create an instance of Orders
     */
    public static function CreateOrders($OrderID)
    {   
        $Orders = new Orders();
        $Orders->OrderID = $OrderID;
        return $Orders;
    }

    /**
     * Constructor for Orders
     */
    public function __construct($uri = "")
    {
        $this->_objectID = Guid::NewGuid();        
        $this->_baseURI = $uri;
        
        $this->_entityMap['Customers'] = 'Customers';
        
        $this->_entityMap['Employees'] = 'Employees';
        
        $this->_entityMap['Order_Details'] = 'Order_Details';
        
        $this->_entityMap['Shippers'] = 'Shippers';
        
        $this->_entityKey[] = 'OrderID';
    
    }

    /**
     * overring getObjectID() functon of Object class
     */
    public function getObjectID()
    {
        return $this->_objectID;
    }

    /**
     * This function returns the entity keys of this entity.
     */
    public function getEntityKeys()
    {
        return $this->_entityKey;
    }

    /**
     * This function set the entity keys of this entity.
     */
    public function setEntityKeys($entityKey)
    {
        $this->_entityKey = $entityKey;
    }

    /**
     * This function returns the related links of this entity.
     */
    public function getRelatedLinks()
    {
        return $this->_relLinks;
    }

    /**
     * This function set the related links of this entity.
     */
    public function setRelatedLinks($relLinks)
    {
        $this->_relLinks = $relLinks;
    }

    /**
     * Function for getting Entity Type Name corrosponding to navigation Name
     */
    public function getActualEntityTypeName($key)
    {
        if (array_key_exists  ($key, $this->_entityMap))
        {
            return ($this->_entityMap[$key]);
        }

        return $key;
    }
}

/**
 * The Products class
 */
class Products extends Object
{
    protected $_entityMap = array();
    protected $_entityKey = array();
    protected $_relLinks  = array();
    protected $_baseURI;
    
    /**
     * EntityProperty
     * NotNullable
     * Edm.Int32
     */
    public $ProductID;
    /**
     * EntityProperty
     * NotNullable
     * Edm.String
     */
    public $ProductName;
    /**
     * EntityProperty
     * Edm.String
     */
    public $QuantityPerUnit;
    /**
     * EntityProperty
     * Edm.Decimal
     */
    public $UnitPrice;
    /**
     * EntityProperty
     * Edm.Int16
     */
    public $UnitsInStock;
    /**
     * EntityProperty
     * Edm.Int16
     */
    public $UnitsOnOrder;
    /**
     * EntityProperty
     * Edm.Int16
     */
    public $ReorderLevel;
    /**
     * EntityProperty
     * NotNullable
     * Edm.Boolean
     */
    public $Discontinued;
    /**
     * NavigationProperty
     */
    public $Categories;
    /**
     * NavigationProperty
     */
    public $Order_Details;
    /**
     * NavigationProperty
     */
    public $Suppliers;

    /**
     * Function to create an instance of Products
     */
    public static function CreateProducts($ProductID, $ProductName, $Discontinued)
    {   
        $Products = new Products();
        $Products->ProductID = $ProductID;
        $Products->ProductName = $ProductName;
        $Products->Discontinued = $Discontinued;
        return $Products;
    }

    /**
     * Constructor for Products
     */
    public function __construct($uri = "")
    {
        $this->_objectID = Guid::NewGuid();        
        $this->_baseURI = $uri;
        
        $this->_entityMap['Categories'] = 'Categories';
        
        $this->_entityMap['Order_Details'] = 'Order_Details';
        
        $this->_entityMap['Suppliers'] = 'Suppliers';
        
        $this->_entityKey[] = 'ProductID';
    
    }

    /**
     * overring getObjectID() functon of Object class
     */
    public function getObjectID()
    {
        return $this->_objectID;
    }

    /**
     * This function returns the entity keys of this entity.
     */
    public function getEntityKeys()
    {
        return $this->_entityKey;
    }

    /**
     * This function set the entity keys of this entity.
     */
    public function setEntityKeys($entityKey)
    {
        $this->_entityKey = $entityKey;
    }

    /**
     * This function returns the related links of this entity.
     */
    public function getRelatedLinks()
    {
        return $this->_relLinks;
    }

    /**
     * This function set the related links of this entity.
     */
    public function setRelatedLinks($relLinks)
    {
        $this->_relLinks = $relLinks;
    }

    /**
     * Function for getting Entity Type Name corrosponding to navigation Name
     */
    public function getActualEntityTypeName($key)
    {
        if (array_key_exists  ($key, $this->_entityMap))
        {
            return ($this->_entityMap[$key]);
        }

        return $key;
    }
}

/**
 * The Region class
 */
class Region extends Object
{
    protected $_entityMap = array();
    protected $_entityKey = array();
    protected $_relLinks  = array();
    protected $_baseURI;
    
    /**
     * EntityProperty
     * NotNullable
     * Edm.Int32
     */
    public $RegionID;
    /**
     * EntityProperty
     * NotNullable
     * Edm.String
     */
    public $RegionDescription;
    /**
     * NavigationProperty
     */
    public $Territories;

    /**
     * Function to create an instance of Region
     */
    public static function CreateRegion($RegionID, $RegionDescription)
    {   
        $Region = new Region();
        $Region->RegionID = $RegionID;
        $Region->RegionDescription = $RegionDescription;
        return $Region;
    }

    /**
     * Constructor for Region
     */
    public function __construct($uri = "")
    {
        $this->_objectID = Guid::NewGuid();        
        $this->_baseURI = $uri;
        
        $this->_entityMap['Territories'] = 'Territories';
        
        $this->_entityKey[] = 'RegionID';
    
    }

    /**
     * overring getObjectID() functon of Object class
     */
    public function getObjectID()
    {
        return $this->_objectID;
    }

    /**
     * This function returns the entity keys of this entity.
     */
    public function getEntityKeys()
    {
        return $this->_entityKey;
    }

    /**
     * This function set the entity keys of this entity.
     */
    public function setEntityKeys($entityKey)
    {
        $this->_entityKey = $entityKey;
    }

    /**
     * This function returns the related links of this entity.
     */
    public function getRelatedLinks()
    {
        return $this->_relLinks;
    }

    /**
     * This function set the related links of this entity.
     */
    public function setRelatedLinks($relLinks)
    {
        $this->_relLinks = $relLinks;
    }

    /**
     * Function for getting Entity Type Name corrosponding to navigation Name
     */
    public function getActualEntityTypeName($key)
    {
        if (array_key_exists  ($key, $this->_entityMap))
        {
            return ($this->_entityMap[$key]);
        }

        return $key;
    }
}

/**
 * The Shippers class
 */
class Shippers extends Object
{
    protected $_entityMap = array();
    protected $_entityKey = array();
    protected $_relLinks  = array();
    protected $_baseURI;
    
    /**
     * EntityProperty
     * NotNullable
     * Edm.Int32
     */
    public $ShipperID;
    /**
     * EntityProperty
     * NotNullable
     * Edm.String
     */
    public $CompanyName;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Phone;
    /**
     * NavigationProperty
     */
    public $Orders;

    /**
     * Function to create an instance of Shippers
     */
    public static function CreateShippers($ShipperID, $CompanyName)
    {   
        $Shippers = new Shippers();
        $Shippers->ShipperID = $ShipperID;
        $Shippers->CompanyName = $CompanyName;
        return $Shippers;
    }

    /**
     * Constructor for Shippers
     */
    public function __construct($uri = "")
    {
        $this->_objectID = Guid::NewGuid();        
        $this->_baseURI = $uri;
        
        $this->_entityMap['Orders'] = 'Orders';
        
        $this->_entityKey[] = 'ShipperID';
    
    }

    /**
     * overring getObjectID() functon of Object class
     */
    public function getObjectID()
    {
        return $this->_objectID;
    }

    /**
     * This function returns the entity keys of this entity.
     */
    public function getEntityKeys()
    {
        return $this->_entityKey;
    }

    /**
     * This function set the entity keys of this entity.
     */
    public function setEntityKeys($entityKey)
    {
        $this->_entityKey = $entityKey;
    }

    /**
     * This function returns the related links of this entity.
     */
    public function getRelatedLinks()
    {
        return $this->_relLinks;
    }

    /**
     * This function set the related links of this entity.
     */
    public function setRelatedLinks($relLinks)
    {
        $this->_relLinks = $relLinks;
    }

    /**
     * Function for getting Entity Type Name corrosponding to navigation Name
     */
    public function getActualEntityTypeName($key)
    {
        if (array_key_exists  ($key, $this->_entityMap))
        {
            return ($this->_entityMap[$key]);
        }

        return $key;
    }
}

/**
 * The Suppliers class
 */
class Suppliers extends Object
{
    protected $_entityMap = array();
    protected $_entityKey = array();
    protected $_relLinks  = array();
    protected $_baseURI;
    
    /**
     * EntityProperty
     * NotNullable
     * Edm.Int32
     */
    public $SupplierID;
    /**
     * EntityProperty
     * NotNullable
     * Edm.String
     */
    public $CompanyName;
    /**
     * EntityProperty
     * Edm.String
     */
    public $ContactName;
    /**
     * EntityProperty
     * Edm.String
     */
    public $ContactTitle;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Address;
    /**
     * EntityProperty
     * Edm.String
     */
    public $City;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Region;
    /**
     * EntityProperty
     * Edm.String
     */
    public $PostalCode;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Country;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Phone;
    /**
     * EntityProperty
     * Edm.String
     */
    public $Fax;
    /**
     * EntityProperty
     * Edm.String
     */
    public $HomePage;
    /**
     * NavigationProperty
     */
    public $Products;

    /**
     * Function to create an instance of Suppliers
     */
    public static function CreateSuppliers($SupplierID, $CompanyName)
    {   
        $Suppliers = new Suppliers();
        $Suppliers->SupplierID = $SupplierID;
        $Suppliers->CompanyName = $CompanyName;
        return $Suppliers;
    }

    /**
     * Constructor for Suppliers
     */
    public function __construct($uri = "")
    {
        $this->_objectID = Guid::NewGuid();        
        $this->_baseURI = $uri;
        
        $this->_entityMap['Products'] = 'Products';
        
        $this->_entityKey[] = 'SupplierID';
    
    }

    /**
     * overring getObjectID() functon of Object class
     */
    public function getObjectID()
    {
        return $this->_objectID;
    }

    /**
     * This function returns the entity keys of this entity.
     */
    public function getEntityKeys()
    {
        return $this->_entityKey;
    }

    /**
     * This function set the entity keys of this entity.
     */
    public function setEntityKeys($entityKey)
    {
        $this->_entityKey = $entityKey;
    }

    /**
     * This function returns the related links of this entity.
     */
    public function getRelatedLinks()
    {
        return $this->_relLinks;
    }

    /**
     * This function set the related links of this entity.
     */
    public function setRelatedLinks($relLinks)
    {
        $this->_relLinks = $relLinks;
    }

    /**
     * Function for getting Entity Type Name corrosponding to navigation Name
     */
    public function getActualEntityTypeName($key)
    {
        if (array_key_exists  ($key, $this->_entityMap))
        {
            return ($this->_entityMap[$key]);
        }

        return $key;
    }
}

/**
 * The Territories class
 */
class Territories extends Object
{
    protected $_entityMap = array();
    protected $_entityKey = array();
    protected $_relLinks  = array();
    protected $_baseURI;
    
    /**
     * EntityProperty
     * NotNullable
     * Edm.String
     */
    public $TerritoryID;
    /**
     * EntityProperty
     * NotNullable
     * Edm.String
     */
    public $TerritoryDescription;
    /**
     * NavigationProperty
     */
    public $Region;
    /**
     * NavigationProperty
     */
    public $Employees;

    /**
     * Function to create an instance of Territories
     */
    public static function CreateTerritories($TerritoryID, $TerritoryDescription)
    {   
        $Territories = new Territories();
        $Territories->TerritoryID = $TerritoryID;
        $Territories->TerritoryDescription = $TerritoryDescription;
        return $Territories;
    }

    /**
     * Constructor for Territories
     */
    public function __construct($uri = "")
    {
        $this->_objectID = Guid::NewGuid();        
        $this->_baseURI = $uri;
        
        $this->_entityMap['Region'] = 'Region';
        
        $this->_entityMap['Employees'] = 'Employees';
        
        $this->_entityKey[] = 'TerritoryID';
    
    }

    /**
     * overring getObjectID() functon of Object class
     */
    public function getObjectID()
    {
        return $this->_objectID;
    }

    /**
     * This function returns the entity keys of this entity.
     */
    public function getEntityKeys()
    {
        return $this->_entityKey;
    }

    /**
     * This function set the entity keys of this entity.
     */
    public function setEntityKeys($entityKey)
    {
        $this->_entityKey = $entityKey;
    }

    /**
     * This function returns the related links of this entity.
     */
    public function getRelatedLinks()
    {
        return $this->_relLinks;
    }

    /**
     * This function set the related links of this entity.
     */
    public function setRelatedLinks($relLinks)
    {
        $this->_relLinks = $relLinks;
    }

    /**
     * Function for getting Entity Type Name corrosponding to navigation Name
     */
    public function getActualEntityTypeName($key)
    {
        if (array_key_exists  ($key, $this->_entityMap))
        {
            return ($this->_entityMap[$key]);
        }

        return $key;
    }
}
  
/**
 * Container class NorthwindEntities, Namespace: NorthwindModel
 */
class NorthwindEntities extends ObjectContext
{
    /**
     * The constructor for NorthwindEntities accepting service URI
     */
    public function __construct($uri = "")
    {
        if (strlen($uri) == 0)
        {
            $uri = DEFAULT_ADO_DOT_NET_SERVICE_URL;
        }
        
        if (Utility::reverseFind($uri, '/') != strlen($uri) - 1) 
        {
           $uri = $uri . '/';
        }

        $this->_baseURI = $uri;
        parent::ObjectContext($this->_baseURI);
        $this->_entities = array("Categories", 
                                 "CustomerDemographics", 
                                 "Customers", 
                                 "Employees", 
                                 "Order_Details", 
                                 "Orders", 
                                 "Products", 
                                 "Region", 
                                 "Shippers", 
                                 "Suppliers", 
                                 "Territories");
        $this->_entitySet2Type = array("categories" => "Categories", 
                                 "customerdemographics" => "CustomerDemographics", 
                                 "customers" => "Customers", 
                                 "employees" => "Employees", 
                                 "order_details" => "Order_Details", 
                                 "orders" => "Orders", 
                                 "products" => "Products", 
                                 "region" => "Region", 
                                 "shippers" => "Shippers", 
                                 "suppliers" => "Suppliers", 
                                 "territories" => "Territories");
        $this->_entityType2Set = array("categories" => "Categories", 
                                 "customerdemographics" => "CustomerDemographics", 
                                 "customers" => "Customers", 
                                 "employees" => "Employees", 
                                 "order_details" => "Order_Details", 
                                 "orders" => "Orders", 
                                 "products" => "Products", 
                                 "region" => "Region", 
                                 "shippers" => "Shippers", 
                                 "suppliers" => "Suppliers", 
                                 "territories" => "Territories");
    }

    /**
     * Functions for adding object to the entityset/collection
     */
    
    /**
     * Add Categories
     */
    public function AddToCategories($object)
    {
        return parent::AddObject('Categories', $object);
    }
    
    /**
     * Add CustomerDemographics
     */
    public function AddToCustomerDemographics($object)
    {
        return parent::AddObject('CustomerDemographics', $object);
    }
    
    /**
     * Add Customers
     */
    public function AddToCustomers($object)
    {
        return parent::AddObject('Customers', $object);
    }
    
    /**
     * Add Employees
     */
    public function AddToEmployees($object)
    {
        return parent::AddObject('Employees', $object);
    }
    
    /**
     * Add Order_Details
     */
    public function AddToOrder_Details($object)
    {
        return parent::AddObject('Order_Details', $object);
    }
    
    /**
     * Add Orders
     */
    public function AddToOrders($object)
    {
        return parent::AddObject('Orders', $object);
    }
    
    /**
     * Add Products
     */
    public function AddToProducts($object)
    {
        return parent::AddObject('Products', $object);
    }
    
    /**
     * Add Region
     */
    public function AddToRegion($object)
    {
        return parent::AddObject('Region', $object);
    }
    
    /**
     * Add Shippers
     */
    public function AddToShippers($object)
    {
        return parent::AddObject('Shippers', $object);
    }
    
    /**
     * Add Suppliers
     */
    public function AddToSuppliers($object)
    {
        return parent::AddObject('Suppliers', $object);
    }
    
    /**
     * Add Territories
     */
    public function AddToTerritories($object)
    {
        return parent::AddObject('Territories', $object);
    }
    

    /**
     * This function returns the entities.
     */
    public function getEntities()
    {
        return $this->_entities;
    }
}

?>